package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface UserMapper {

    //--1--查询所有
    @Select("select * from user")
    List<User> selectAll();

    //--4-- 分页查询
    @Select(" select * from user limit #{begin},#{pageSize}")
    List<User> selectByPage(int begin,int pageSize);

    @Select("select count(*) from user")
    int selectCount();

    //--3--添加
    @Insert(" insert into user values(null,#{username},#{email},#{age})")
    int add(User user);

    //--4-- 删除 delete from tb_brand where id = 5
    @Delete("delete from user where id = #{id}")
    int deleteById(int id);

    //--5-- 修改
    @Update(" update user set" +
            " username = #{username}," +
            " email = #{email}," +
            " age = #{age}"+
            " where id = #{id}")
    int update(User user);


//
//    //--3-- 批量删除
//    void deleteByIds(@Param("ids") int[] ids);
//
//    //--4-- 分页查询
//    @Select(" select * from tb_brand" +
//            " limit #{begin},#{pageSize}")
//    @ResultMap("brandResultMap")
//    List<User> selectByPage(@Param("begin") int begin,
//                             @Param("pageSize") int pageSize);
//    //--4-- 返回总条数
//    @Select("select count(*) from tb_brand")
//    int selectTotalCount();

//    //--5-- 条件查询
////    @Select(" select * from tb_brand" +
////            " limit #{begin},#{pageSize}")
////    @ResultMap("brandResultMap")
//    List<Brand> selectByPageCondition(
//            @Param("begin") int begin,
//            @Param("pageSize") int pageSize,
//            @Param("conditionBrand") Brand conditionBrand
//    );
//    //--5-- 条件总数
//    int selectTotalCountByCondition(Brand conditionBrand);
//
//    //--6-- 修改
//    @Update(" update tb_brand set" +
//            " brand_name = #{brandName}," +
//            " company_name = #{companyName}," +
//            " ordered = #{ordered}," +
//            " description = #{description}," +
//            " status = #{status}" +
//            " where id = #{id}")
//    @ResultMap("brandResultMap")
//    void updateById(Brand brand);
//
//    //--7-- 删除 delete from tb_brand where id = 5
//    @Delete("delete from tb_brand where id = #{id}")
//    void deleteById(Brand brand);


}
